package palms.idserver;

import java.io.UnsupportedEncodingException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;

import javax.crypto.spec.SecretKeySpec;

import palms.security.PalmsSecurityManager;

public class IdLogic {

	private int siport;
	private int slport;
	
	private String slip;
	
	private HashMap<String,String> userlist;
	
	private SecretKeySpec keySI;

	public IdLogic(){
		this.userlist = new HashMap<String,String>();
		this.init();
	}
	
	public void init(){
		//Populate user list
		this.userlist.put("fireman", "inseguro");

		this.setSiport(56423);
		this.setSlport(56424);
		
		try {
			
			this.setSlip(InetAddress.getLocalHost().getHostAddress());
			
			//SI key
			String sik = "identificacaoidenificacaoidentificacao";
			this.setKeySI(PalmsSecurityManager.getKeyFromString(sik));
			
		} catch (NoSuchAlgorithmException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public int getSiport() {
		return siport;
	}

	public void setSiport(int siport) {
		this.siport = siport;
	}

	public int getSlport() {
		return slport;
	}

	public void setSlport(int slport) {
		this.slport = slport;
	}

	public String getSlip() {
		return slip;
	}

	public void setSlip(String slip) {
		this.slip = slip;
	}

	public HashMap<String, String> getUserlist() {
		return userlist;
	}

	public void setUserlist(HashMap<String, String> userlist) {
		this.userlist = userlist;
	}

	public SecretKeySpec getKeySI() {
		return keySI;
	}

	public void setKeySI(SecretKeySpec keySI) {
		this.keySI = keySI;
	}
	
}
